package cn.le.api;

import cn.le.dto.PropertyDTO;
import cn.le.service.PropertyService;
import cn.le.util.ResponseFactory;
import cn.le.vo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(value = "属性功能")
@RestController
@RequestMapping(value = "/api/property")
public class PropertyApi {

    @Autowired
    private PropertyService propertyService;

    @ApiOperation(value = "新增属性",notes = "新增属性")
    @RequestMapping(value = "add",method = RequestMethod.POST)
    public ResponseVO add(@RequestBody @Valid PropertyDTO dto){
        propertyService.add(dto);
        return ResponseFactory.ok("新增成功");
    }

    @ApiOperation(value = "属性redis",notes = "属性redis")
    @RequestMapping(value = "refresh",method = RequestMethod.POST)
    public ResponseVO refresh(){
        propertyService.refresh();
        return ResponseFactory.ok("刷新完成");
    }
}
